<template>
  <ul class="right-list-container">
    <li v-for="(item, i) in list" :key="i">
      <div @click="handleClick(item)" :class="{ active: item.active }">{{
        item.name
      }}</div>
      <div
        @click="handleClick(item)"
        v-if="item.aside"
        class="aside"
        :class="{ active: item.active }"
        >{{ item.aside }}</div
      >
      <RightList :list="item.children" @select="handleClick(item)" />
    </li>
  </ul>
</template>

<script>
export default {
  //传入一个参数，形式是数组，[name:"",active:"true",children:{}]
  name: "RightList",
  props: {
    list: Array,
    default: () => {},
  },
  methods: {
    handleClick(item) {
      if (!item.active) {
        this.$emit("select", item);
      }
    },
  },
};
</script>

<style scoped lang="less">
@import "~@/styles/var.less";
.right-list-container {
  list-style: none;
  margin: 0;
  padding: 0;
  
  .right-list-container {
    margin-left: 1em;
  }
  li {
    font-size: 14px;
    min-height: 40px;
    line-height: 40px;
    cursor: pointer;
  }
  div{
    width: 100%;
    height: 100%;
    padding: 5px;
    color: #333;
     &:hover{
      background-color: #f3f5f8fd;
    }
  }
  .active {
    color: @active;

  }
  .aside {
    position: relative;
    font-size: 12px;
    margin-left: 1em;
    color: @lightWords;
  }
}
</style>